import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import zhCn from "dayjs/locale/zh-cn";
dayjs.locale(zhCn);
dayjs.extend(relativeTime); // use plugin

export const formatDate = (
  date: string | number | Date,
  format = "YYYY-MM-DD HH:mm:ss"
): string => {
  return dayjs(date).format(format);
};

export const dateCurrentFromNow = (date: string | number | Date): string => {
  return dayjs().to(dayjs());
};
